import { IRouteComponentProps, RequestConfig, history } from 'umi';
import NProgress from 'nprogress';

export const request: RequestConfig = {
  timeout: 1000000,
  errorConfig: {},
  middlewares: [],
  requestInterceptors: [(url, options) => {
    return {
      url,
      options: { ...options, interceptors: true },
    };
  }],
  responseInterceptors: [],
};
export function onRouteChange({location, matchedRoutes }:any) {
  NProgress.start();
  // NProgress.configure({speed: 500});
  setTimeout(() => {
      NProgress.done()
  }, 1000);
  if (matchedRoutes.length) {
    document.title = matchedRoutes[matchedRoutes.length - 1].route.title || '';
  }
  if(location.pathname == '/'){
    console.log(location.pathname);
    history.replace('/article/article')
  } 
}
